/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mysimpatico.sqlwrapper;

import com.mysimpatico.sqlwrapper.SqlWrapper.SelectOption;

/**
 *
 * @author simpatico
 */
public class SelectCoreQueryBuilder {

    private SelectCoreQuery result;

    public void buildResult(final SelectableFrom[] tables, final Column[] cols) {
        final ResultList resultList = new ResultList();
        for (int i = 0; i < cols.length; i++) {
            resultList.addNode(new ColumnNode(tables[i], cols[i]));
        }
        result = new SelectCoreQuery(null, SqlWrapper.SelectOption.NONE, resultList);
        buildFromList(tables);
    }

    protected void buildFromList(final SelectableFrom[] tables) {
        final ResultList tablesList = new ResultList();
        for(SelectableFrom t: tables) tablesList.addNode(new TableNode(t));
        result.fromList = tablesList;
    }

    public void buildSelectOption(final SelectOption selectOption) {
        result.selectOption = selectOption;
    }

    public SelectQuery getResult() {
        return result;
    }
}
